﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MagicalDesktop.Simulation;

namespace MagicalDesktop
{
    /// <summary>
    /// Interaction logic for AddAccount.xaml
    /// </summary>
    public partial class AddAccount : UserControl
    {
        public AddAccount()
        {
            InitializeComponent();
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_services.SelectedItem != null)
                _loginPanel.Visibility = Visibility.Visible;
            else _loginPanel.Visibility = Visibility.Collapsed;
        }

        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            var service = _services.SelectedItem as Service;
            service.Login(_userNameTextBox.Text, _passwordTextBox.Password);
        }

        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            Shell.Instance.RefreshView();
        }
    }
}
